package com.rlm.parken.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.rlm.parken.client.content.Liste;
import com.rlm.parken.client.content.StartSeite;
import com.rlm.parken.client.views.DatenTabelleAusgeben;

public class TopNavigation extends Composite implements ClickHandler {

	private final HorizontalPanel hpanel = new HorizontalPanel();
	private final Button buttonStart = new Button("Startseite");
	private final Button buttonListe = new Button("Liste");
	private final Button buttonDatentabelle = new Button("Datentabelle");

	@Override
	public void onClick(ClickEvent event) {

		Widget sender = (Widget) event.getSource();

		if (sender == buttonStart) {
			FlowControl.go(new StartSeite());
			History.newItem("page0");
			Window.setTitle("Startseite");
		}
		if (sender == buttonListe) {
			FlowControl.go(new Liste());
		}
		if (sender == buttonDatentabelle) {
			FlowControl.go(new DatenTabelleAusgeben());
		}
	}

	public TopNavigation() {
		buttonStart.addClickHandler(this);
		buttonListe.addClickHandler(this);
		buttonDatentabelle.addClickHandler(this);

		hpanel.add(buttonStart);
		hpanel.add(buttonListe);
		hpanel.add(buttonDatentabelle);

		initWidget(hpanel);
	}

}
